# @Author: Eric Ito
# @Date: 1/28/2009
# @Name: Project Euler Problem 25


"""
What is the first term in the fibonacci sequence to
contain 1000 characters
"""

"""
Algorithm

I created a fibonacci value generator instead of calculating the new number
each time... it stores them in a dictionary and yields them to the calling
function which checks to see if it's length == 1000
"""
def fibGenerator():
    fib = {}
    fib[1] = 1
    fib[2] = 1
    for i in range(3,100000):
        fib[i] = fib[i-1] + fib[i-2]
        yield i,fib[i]

def main():
    for i,j in fibGenerator():
        if len(str(j)) == 1000:
            print i
            break

if __name__ == '__main__':
    main()